package com.example.onion.hxchat.mvvm;

import android.app.Application;

import androidx.annotation.NonNull;
import androidx.lifecycle.AndroidViewModel;
import androidx.lifecycle.LiveData;

import com.example.onion.hxchat.room.entity.Apply;
import com.example.onion.hxchat.room.entity.Friend;
import com.example.onion.hxchat.room.repositorywc.FriendRepository;
import com.example.onion.hxchat.room.wcdatabase.MyDataBaseWc;

import java.util.List;

/**
 * @author:onion
 * @data: 2020/7/8
 */
public class WcFriendViewModel extends AndroidViewModel {

    //将“秒钟”这个字段用MutableLiveData包装起来
    //LiveData是一个抽象类，不能直接使用，所以通常我们使用它的直接子类MutableLiveData。
    private LiveData<List<Friend>> friends;

    private FriendRepository repository;
    public WcFriendViewModel(@NonNull Application application) {
        super(application);
        repository = new FriendRepository(application);
    }

    public void insertFriend(Friend... friends)
    {
        repository.insertMaster(friends);
    }

    public void deltetFreind(String ownerId,String userId){
        repository.DeleteFriend(ownerId,userId);
    }
    public LiveData<List<Friend>> getLiveFriend()
    {
        return repository.getAllFriends();
    }
    public LiveData<List<Friend>> getOwnFriends(String userId)
    {
        return repository.getUsersFriends(userId);
    }


}
